package com.example.pei.ithinklearnt.view.customview;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;


import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;

/**
 * 这是个消耗事件的recycleview，不管什么滑动事件都能传到这里并且传递下去，用于在某些地方防止侧滑栏被打开
 * Created by Pei on 2018/4/13.
 */

public class MyConsumedRecycleView extends RecyclerView {

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        switch (ev.getAction()) {
            case ACTION_DOWN:
                getParent().requestDisallowInterceptTouchEvent(true);  //让父view 不要拦截我的事件
                break;
        }
        return super.onInterceptTouchEvent(ev);
    }


    public MyConsumedRecycleView(Context context) {
        super(context);
    }

    public MyConsumedRecycleView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyConsumedRecycleView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
}
